﻿/*
 * ********************************************************************************************************************
 *
 *               iFHS7.
 *              ;BBMBMBMc                  rZMBMBR              BMB
 *              MBEr:;PBM,               7MBMMEOBB:             BBB                       RBW
 *     XK:      BO     SB.     :SZ       MBM.       c;;     ir  BBM :FFr       :SSF:    ;xBMB:r   iuGXv.    i:. iF2;
 *     DBBM0r.  :D     S7   ;XMBMB       GMBMu.     MBM:   BMB  MBMBBBMBMS   WMBMBMBBK  MBMBMBM  BMBRBMBW  .MBMBMBMBB
 *      :JMRMMD  ..    ,  1MMRM1;         ;MBMBBR:   MBM  ;MB:  BMB:   MBM. RMBr   sBMH   BM0         UMB,  BMB.  KMBv
 *     ;.   XOW  B1; :uM: 1RE,   i           .2BMBs  rMB. MBO   MBO    JMB; MBB     MBM   BBS    7MBMBOBM:  MBW   :BMc
 *     OBRJ.SEE  MRDOWOR, 3DE:7OBM       .     ;BMB   RMR7BM    BMB    MBB. BMB    ,BMR  .BBZ   MMB   rMB,  BMM   rMB7
 *     :FBRO0D0  RKXSXPR. JOKOOMPi       BMBSSWBMB;    BMBB:    MBMB0ZMBMS  .BMBOXRBMB    MBMDE RBM2;SMBM;  MBB   xBM2
 *         iZGE  O0SHSPO. uGZ7.          sBMBMBDL      :BMO     OZu:BMBK,     rRBMB0;     ,EBMB  xBMBr:ER.  RDU   :OO;
 *     ,BZ, 1D0  RPSFHXR. xWZ .SMr                  . .BBB
 *      :0BMRDG  RESSSKR. 2WOMBW;                   BMBMR
 *         i0BM: SWKHKGO  MBDv
 *           .UB  OOGDM. MK,                                          Copyright (c) 2015-2019.  斯伯坦机器人
 *              ,  XMW  ..
 *                  r                                                                     All rights reserved.
 *
 * ********************************************************************************************************************
 */

using System.Collections.ObjectModel;
using System.ComponentModel;

namespace MongoPI
{
    /// <summary>
    /// 数据库资源管理器Item
    /// </summary>
    public class ExplorerViewItem : INotifyPropertyChanged
    {
        /// <summary>
        /// 实现INotifyPropertyChanged接口
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// 节点类型
        /// </summary>
        public enum ItemType
        {
            Server,             // 服务器
            Database,           // 数据库
            CollectionList,     // 集合列表
            Collection,         // 集合
            ViewList,           // 视图列表
            View,               // 视图
            UserList,           // 用户列表
            RoleList            // 角色列表
        };

        /// <summary>
        /// 父节点
        /// </summary>
        public ExplorerViewItem Parent;

        /// <summary>
        /// 名称
        /// </summary>
        public string mName;
        public string Name
        {
            get
            {
                return mName;
            }
            set
            {
                mName = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Name)));
            }
        }

        /// <summary>
        /// 图标
        /// </summary>
        public string mIcon;
        public string Icon
        {
            get
            {
                return mIcon;
            }
            set
            {
                mIcon = value;
                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Icon)));
            }
        }

        /// <summary>
        /// 绑定对象
        /// </summary>
        public object BindObject { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        public ItemType NodeType { get; set; }

        /// <summary>
        /// 子节点
        /// </summary>
        public ObservableCollection<ExplorerViewItem> Children { get; set; } = new ObservableCollection<ExplorerViewItem>();

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="parent">父节点</param>
        /// <param name="type">节点类型</param>
        /// <param name="name">名称</param>
        /// <param name="icon">图标</param>
        public ExplorerViewItem(ExplorerViewItem parent, ItemType type, string name, string icon)
        {
            Parent = parent;
            NodeType = type;
            Name = name;
            Icon = icon;
            return;
        } // Function ExplorerViewItem()
    } // Class DatabaseTreeViewItem
} // Namespace MongoPI
